package com.shiguiwu.springmybatis.javabase.string;

import cn.hutool.core.util.StrUtil;
import lombok.extern.slf4j.Slf4j;

import java.util.Arrays;
import java.util.Iterator;
import java.util.Map;
import java.util.Optional;
import java.util.Scanner;
import java.util.Set;
import java.util.stream.Collectors;

/**
 * @description: zifuc
 * @author: stone
 * @date: Created by 2022/10/19 11:20
 * @version: 1.0.0
 * @pakeage: com.shiguiwu.springmybatis.string
 */
@Slf4j
public class StringTests {

    public static void main(String[] args) {

        //String a = "sdadwdawdadad";
        //int i = lengthOfLongestSubstring(a);
        //System.out.println("有效长度为 ===> "+ a);


        testScanner();

    }

    public static int lengthOfLongestSubstring(String val) {
        if (StrUtil.isBlank(val)) {
            return 0;
        }

        String[] split = val.split("");

        Set<String> collect = Arrays.stream(split).collect(Collectors.toSet());

        return collect.size();

    }


    /**
     * 键盘输入
     */
    public static void testScanner() {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()) {
            String next = scanner.nextLine();
            log.info("我输入的键盘文字 ===> {}", next);
            if ("e".equals(next)) {
                break;
            }

        }

        log.info("键盘结束 ===>");



    }
}
